package com.jt.service;

import java.util.HashMap;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.UserMapper;
import com.jt.pojo.User;

@Service
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserMapper userMapper;

	@Override
	public boolean findCheckUser(String param, Integer type) {
		//1.需要将type类型转化为具体的字段
		//String column=(type==1)?"username":(type==2?"phone":"email");//使用map集合效率最高
		Map<Integer, String> map=new HashMap<>();
		map.put(1, "username");
		map.put(2, "phone");
		map.put(3, "email");
		String column=map.get(type);
		
		QueryWrapper<User> queryWrapper=new QueryWrapper<>();
		queryWrapper.eq(column, param);
		User user=userMapper.selectOne(queryWrapper);
		
		//User user2=userMapper.findUserByCheck(column,param);
		return user==null?false:true;
	}
	
	
	
}
